<?php

define('ACC',true);

require ('../includes/init.php');
require ('left.php');

if(isset($_SESSION['user_id']) && isset($_SESSION['username'])){
	$smarty->assign('SESSION', $_SESSION);
}

$goods = new GoodsModel();

if(isset($_GET['goods_id']) && (($_GET['goods_id'] + 0) >=0)){
	
	$goods_id = $_GET['goods_id'] + 0;
	$good_info = $goods->get_good_info($goods_id);
	$good_info['add_time'] = date('Y-m-d H:i:s', $good_info['add_time']);
	
	$good_attrs = $goods->get_good_attrs($good_info['goods_id']);
	
	$cat_info = $goods->get_cat_info($goods_id);
	$parent = $goods->get_parent($cat_info['cat_id']);

	$ur_here = '当前位置:&nbsp;<a href="index.php">首页&nbsp;</a>&gt;';
	$ur_here .= '<a href="category.php?cat_id=' . $parent['cat_id'] . '">&nbsp;' . $parent['cat_name'] . '</a>&nbsp;&gt;';
	$ur_here .= '<a href="category.php?cat_id=' . $cat_info['cat_id'] . '">&nbsp;' . $cat_info['cat_name'] . '</a>&nbsp;&gt;&nbsp;' . $good_info['goods_name'];
	$smarty->assign('ur_here', $ur_here);

	$smarty->assign('goods_id', $goods_id);
	$smarty->assign('good_attrs', $good_attrs);
	$smarty->assign('good_info', $good_info);
	
	$smarty->display('./front/goods.html');
	
}else if(isset($_POST['act']) && $_POST['act'] == 'history'){
	
	$ids = $_POST['ids'];
	
	$goods = $goods->get_goods($ids);
	foreach($ids as $key => $val){
		foreach($goods as $k => $v){
			if($val == $v['goods_id']){
				$goods_list[] = $v;
			}
		}
	}
	
	echo json_encode($goods_list);
	return;
	
}












